package Messages;

import java.io.IOException;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import Server.SQLConnection;
import ocsf.server.ConnectionToClient;


public class MessageDeleteScenario {

	private ConnectionToClient client ;


public MessageDeleteScenario(ArrayList<Object> msg, ConnectionToClient client) {
		
		this.client= client ;
		
		
	}

public void Run(String ScenarioName) throws SQLException, IOException {
	SQLConnection sc = new SQLConnection();
	
	java.sql.PreparedStatement ScenarioTemp = sc.getConnection().prepareStatement("DELETE FROM hts.sbank where SName='"+ScenarioName+"' ;");

	ScenarioTemp.executeUpdate();
	
	ScenarioTemp.close();
	
	java.sql.PreparedStatement ScenarioTemp1 = sc.getConnection().prepareStatement("DROP TABLE "+ScenarioName+";");

	ScenarioTemp1.executeUpdate();
	
	ScenarioTemp1.close();
	
	java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("SELECT * FROM hts.SBank;");
	ResultSet SuppRes= ps.executeQuery();
	ArrayList<Object> Bank =new ArrayList<Object>();
	Bank.add("Bank");
	while (SuppRes.next())
	{
		Bank.add(SuppRes.getInt(1));
		Bank.add(SuppRes.getString(2));
		Bank.add(SuppRes.getString(3));
		Bank.add(SuppRes.getString(4));

	}
	client.sendToClient(Bank);
	
	

	
	
}

}
